# 对RPG::Cache的修改，使得加载windowskin时可以修改色相
module RPG
  module Cache
    def self.windowskin(filename, hue = 0)
      self.load_bitmap("Graphics/Windowskins/", filename, hue)
    end
  end
end

# 对地图类的修改，方便读取地图名称
class Game_Map
  def name
    $data_mapinfos[@map_id].name
  end
end

# 对event类的修改，使event可被读取
class Game_Event < Game_Character
  attr_reader :event
end

# 对标题类的修改，使其加载地图名称
class Scene_Title
  alias main_old main
  def main
    $data_mapinfos = load_data("Data/MapInfos.rxdata")
    main_old
  end
end

# 对存档界面的修改，使返回到菜单时index正确
class Scene_Save < Scene_File
  def on_decision(filename)
    # 演奏存档 SE
    $game_system.se_play($data_system.save_se)
    # 写入存档数据
    file = File.open(filename, "wb")
    write_save_data(file)
    file.close
    # 如果被事件调用
    if $game_temp.save_calling
      # 清除存档调用标志
      $game_temp.save_calling = false
      # 切换到地图画面
      $scene = Scene_Map.new
      return
    end
    # 切换到菜单画面
    $scene = Scene_Menu.new(0)
  end

  def on_cancel
    # 演奏取消 SE
    $game_system.se_play($data_system.cancel_se)
    # 如果被事件调用
    if $game_temp.save_calling
      # 清除存档调用标志
      $game_temp.save_calling = false
      # 切换到地图画面
      $scene = Scene_Map.new
      return
    end
    # 切换到菜单画面
    $scene = Scene_Menu.new(0)
  end
end
